﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace MidApp
{
    public class ManagePossession
    {
        /// <summary>
        ///MEtoda provede prirazeni akce k tymu.
        ///</summary>
        public static void AssignEventToTeam(int EventID, int TeamID)
        {
            var db = MidApp.LinqUse.DBConn;

            AppLib.Possession poss = new AppLib.Possession();

            poss.TeamID = TeamID;
            poss.EventID = EventID;

            db.Possessions.InsertOnSubmit(poss);
            db.SubmitChanges();

        }
        /// <summary>
        ///Metoda vrati tym, kteremu patri akce
        ///</summary>
        public static AppLib.Possession GetTeamInChargeOfEvent(int EventID)
        {
            var db = MidApp.LinqUse.DBConn;

            var team = (from Possession in db.Possessions where Possession.EventID == EventID select Possession).First();

            return team;

        }
        /// <summary>
        ///Metoda vraci vsechny akce nalezici tymu
        ///</summary>
        public static List<AppLib.Possession> GetAllEventsAssignedToTeam(int TeamID)
        {
            var db = MidApp.LinqUse.DBConn;

            var events = (from Possession in db.Possessions where Possession.TeamID == TeamID select Possession).ToList();

            return events;
        }
    }
    
}
